package com.poly.system.factory;

import com.poly.common.core.domain.R;
import com.poly.system.RemoteDeptService;
import com.poly.system.RemoteUserService;
import com.poly.system.domain.SysDept;
import com.poly.system.domain.SysUser;
import com.poly.system.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 用户服务降级处理
 * 
 * @author Yang huijing
 */
@Component
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteDeptFallbackFactory.class);

    @Override
    public RemoteDeptService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteDeptService()
        {

            @Override
            public R<List<SysDept>> getCacheDeptList(List<Long> deptIdList) {
                return R.fail("获取缓存部门列表失败:" + throwable.getMessage());
            }

            @Override
            public R<String> getCacheDeptName(List<Long> deptIdList) {
                return R.fail("获取缓存部门名称失败:" + throwable.getMessage());
            }
        };
    }
}
